package edu.jamestang.yeb.service;

import com.baomidou.mybatisplus.extension.service.IService;
import edu.jamestang.yeb.entity.Admin;
import edu.jamestang.yeb.entity.Role;
import edu.jamestang.yeb.util.Resp;
import org.springframework.security.core.Authentication;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author JamesTang
 * @since 2021-12-13
 */
public interface AdminService extends IService<Admin> {

    /**
     * login
     * @param username username
     * @param password password
     * @param code captcha code
     * @param request http request
     * @return resp
     */
    Resp login(String username, String password, String code, HttpServletRequest request);


    /**
     * get user entity
     * @param username username
     * @return user obj
     */
    Admin getAdminByUsername(String username);

    /**
     * get user role list
     * @param adminId admin id
     * @return role list
     */
    List<Role> getRoles(Integer adminId);

    /**
     * get admin list by keyword
     * @param keyword keyword
     * @return admin list
     */
    List<Admin> getAllAdmins(String keyword);

    /**
     * Update Admin role
     * @param adminId adminId
     * @param rids role id list
     * @return Response
     */
    Resp updateAdminRole(Integer adminId, Integer[] rids);

    /**
     * Update current user's password
     * @param oldPass The old password
     * @param pass New password
     * @param adminId User id
     * @return Response
     */
    Resp updateAdminPassword(String oldPass, String pass, Integer adminId);

    /**
     * Update user's icon
     * @param file icon
     * @param id user id
     * @param authentication authentication obj
     * @return Response
     */
    Resp updateAdminUserFace(MultipartFile file, Integer id, Authentication authentication);
}
